package com.chance.cc.crawler.development.bootstrap.weixin.api;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.HttpConfig;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.*;

/**
 * @ClassName wx
 * @Description TODO
 * @Author songding
 * @Date 2021/11/11 16:18
 * @Version 1.0
 * 根据账号获取过去某一时间区间内的发文，每天14:00后更新前一天的数据
 **/
public class WeiXinApiAccount {
    public static final String domain = "weixin";
    public static final String site = "apiAccount";
    public static void main(String[] args) {
        limit();
    }
    public static void limit(){
        String url = "https://api.newrank.cn/api/sync/weixin/account/articles_content";
        CrawlerRequestRecord requestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl(url)
                .httpConfig(HttpConfig.me(domain))
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.dateRange)
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24*7,null))
                .needWashed(false)
                .needParsed(false)
                .build();
        requestRecord.setSkipPipeline(true);
        requestRecord.setDownload(false);
        requestRecord.tagsCreator().bizTags().addDomain(domain);
        requestRecord.tagsCreator().bizTags().addSite(site);
        //关键词
        requestRecord.tagsCreator().bizTags().addCustomKV("startTime","2021-11-08 00:00:00");
        requestRecord.tagsCreator().bizTags().addCustomKV("endTime","2021-11-13 00:00:00");
        requestRecord.tagsCreator().bizTags().addCustomKV("pageSize","1");
        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest("keyword",turnPageItem)
                .httpUrl("http://192.168.1.215:9599/v1/meta/weixin/keys?site=apiAccount")
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();

        DevCrawlerController.builder()
                .triggerInfo(domain,domain,System.currentTimeMillis(),domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline()
                .fileResultPipeline("F:\\chance_log\\weibo\\account.log",true)
                .requestRecord(requestRecord)
                .supportRecord(keywordRecord)
                .build("com.chance.cc.crawler.development.scripts.weixin")
                .start();
    }
}
